package com.hzspace.advice.init;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;

/**
 * @Author: LiuHao
 * @Descirption:
 * @Date: 2020/2/28_22:13
 */
@ControllerAdvice
public class GlobalInitHandler {


    /**
     * 前端请求参数 author.name
     * @param binder
     */
    @InitBinder("author")
    public void initAuthor(WebDataBinder binder){
        binder.setFieldDefaultPrefix("author.");
    }

    /**
     * 前端请求参数 book.name
     * @param binder
     */
    @InitBinder("book")
    public void initBook(WebDataBinder binder){
        binder.setFieldDefaultPrefix("book.");
    }

}
